﻿/**
 * @file   FITKAbaqusAdaptorBoundary.h
 * @brief Abaqus Boundary 适配器 用于读取INP过程中的Load解析
 * @author liuzhonghua (liuzhonghuaszch@163.com)
 * @date 2024-04-11
 */
#ifndef __FITKABAQUSADAPTORBOUNDARY__H__
#define __FITKABAQUSADAPTORBOUNDARY__H__

#include "FITKAbaqusAbstractAdaptor.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"
#include "FITKAbaqusGetInterfaceTool.h"
 //前置声明
ForwardDeclarNS(AbaqusData, FITKDataCase)
ForwardDeclarNS(Interface, FITKAbaAbstractBoundaryCondition)
ForwardDeclarNS(Interface, FITKAbaBoundaryConditionDisplacement)
ForwardDeclarNS(Interface, FITKAbaBoundaryConditionSymmetry)
ForwardDeclarNS(Interface, FITKAbaBoundaryConditionVelocity)
namespace IO
{
    /**
     * @brief Abaqus Load 读写适配器
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date 2024-03-26
     */
    class FITKAbaqusIOINPAPI FITKAbaqusAdaptorBoundary : public FITKAbaqusAbstractAdaptor
    {
    public:
        explicit FITKAbaqusAdaptorBoundary() = default;
        ~FITKAbaqusAdaptorBoundary() = default;

        /**
         * @brief 获取适配器数据类型名
         * @return 适配器数据类型名
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-03-26
         */
        QString getAdaptorClass() override;

        /**
         * @brief 设置算例数据对象
         * @param caseData
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-03-26
         */
        void setCaseData(AbaqusData::FITKDataCase* caseData);

        /**
         * @brief 设置关键字所在的行数据
         * @param line 关键字所在的行数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-07
         */
        void setLineKeywords(QString line);

        /**
         * @brief 设置写出的数据
         * @param op 关键字op数据
         * @param stepId 分析步id
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-15
         */
        void setWriterData(QString op, int stepId);

        /**
         * @brief 适配器读取 CFORCE
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-03-26
         */
        bool adaptR() override;

        /**
         * @brief 适配器写出
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-03-26
         */
        bool adaptW() override;

    private:
        /**
         * @brief 读取对称/反对称/固定边界条件
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-11
         */
        bool boundaryConditionSymmetryR();

        /**
         * @brief 读取位移/旋转边界条件
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-11
         */
        bool boundaryConditionDisplacementR();

        /**
         * @brief 读取速度/角速度条件
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-07-09
         */
        bool boundaryConditionVelocityR();

        /**
         * @brief 写出对称/反对称/固定边界条件
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-11
         */
        bool boundaryConditionSymmetryW();

        /**
         * @brief 写出位移/旋转边界条件
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-11
         */
        bool boundaryConditionDisplacementW();

        /**
        * @brief 写出速度/角速度条件
        * @return 状态 true成功， false失败
        * @author liuzhonghua (liuzhonghuaszch@163.com)
        * @date 2024-07-09
        */
        bool boundaryConditionVelocityW();

        /**
         * @brief 设置取消激活的stepid
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-17
         */
        void setStepDeactiveR();

    private:

        /**
         * @brief 算例数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-03-26
         */
        AbaqusData::FITKDataCase* _caseData{};
        /**
         * @brief 关键字的行
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-07
         */
        QString _keywordsLine{};
        /**
         * @brief op数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-15
         */
        QString _op{};
        /**
         * @brief 分析步id
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-15
         */
        int _stepId{ 0 };
        /**
         * @brief 用于记录数值类型
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-17
         */
        int _typeU{ -1 };
        /**
         * @brief 获取接口 工具类
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-25
         */
        FITKAbaqusGetInterfaceTool _tool;
    };
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaAbstractBoundaryCondition, FITKAbaqusAdaptorBoundary, 1)
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaBoundaryConditionDisplacement, FITKAbaqusAdaptorBoundary, 2)
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaBoundaryConditionSymmetry, FITKAbaqusAdaptorBoundary, 3)
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaBoundaryConditionVelocity, FITKAbaqusAdaptorBoundary, 4)
}

#endif